package org.eclipse.emc.epsilon.rdbms.core.typemapper;

/**
 * This maps the Java data type to the SQL Data types and provides a default value for the SQL Data Type. 
 *  
 * @param  typeName  This is the name of the Java Data Type which needs to be mapped
 * @param  
 * @return a default value for the SQL Data Type.
 */
public class TypeMapper 
{
	public String  getMappedDataTypeDefault(String typeName)
	{
    String defaultValue;
	if(typeName.equals("BIGINT"))
   {
	   //SQLdataType = "BIGINT";
	   defaultValue = "0";
   }
   else if (typeName.equals("BINARY"))
   {
	   //SQLdataType = "CHAR FOR BIT DATA ";
	   defaultValue = "0";
   }   
   else if (typeName.equals("BIT1"))
   {
	   //SQLdataType = "CHAR FOR BIT DATA";
	   defaultValue = "0";
   }   
   else if (typeName.equals("BLOB"))
   {
	   //SQLdataType = "BLOB (JDBC 2.0 and up)";
	   defaultValue = "0";
   }   
   else if (typeName.equals("CHAR"))
   {
	   //SQLdataType = "CHAR";
	   defaultValue = "EPSILON";
   }   
   else if (typeName.equals("CLOB"))
   {
	   //SQLdataType = "CLOB (JDBC 2.0 and up)";
	   defaultValue = "EPSILON";
   }   
   else if (typeName.equals("DATE"))
   {
	   //SQLdataType = "DATE";
	   defaultValue = "1900-01-01 00:00:00.000";
   }   
   else if (typeName.equals("DECIMAL"))
   {
	   //SQLdataType = "DECIMAL";
	   defaultValue = "0";
   }   
   else if (typeName.equals("DOUBLE"))
   {
	   //SQLdataType = "DOUBLE PRECISION";
	   defaultValue = "0";
   }   
   else if (typeName.equals("FLOAT"))
   {
	   //SQLdataType = "DOUBLE PRECISION2";
	   defaultValue = "0";
   }   
   else if (typeName.equals("INTEGER"))
   {
	   //SQLdataType = "INTEGER";
	   defaultValue = "0";
   }   
   else if (typeName.equals("LONG VARCHAR FOR BIT DATA"))
   {
	   //SQLdataType = "BIGINT";
	   defaultValue = "0";
   }   
   else if (typeName.equals("LONG VARCHAR"))
   {
	   //SQLdataType = "BIGINT";
	   defaultValue = "0";
   }   
   else if (typeName.equals("NULL"))
   {
	   //SQLdataType = "Not a data type; always a value of a particular type";
	   defaultValue = "0";
   }   
   else if (typeName.equals("NUMERIC"))
   {
	   //SQLdataType = "DECIMAL";
	   defaultValue = "0";
   }   
   else if (typeName.equals("REAL"))
   {
	   //SQLdataType = "REAL";
	   defaultValue = "0";
   }   
   else if (typeName.equals("SMALLINT"))
   {
	   //SQLdataType = "SMALLINT";
	   defaultValue = "0";
   }   
   else if (typeName.equals("SQLXML3"))
   {
	   //SQLdataType = "XML";
	   defaultValue = "0";
   }   
   else if (typeName.equals("TIME"))
   {
	   //SQLdataType = "TIME";
	   defaultValue = "00:00:00.000";
   }   
   else if (typeName.equals("TIMESTAMP"))
   {
	   //SQLdataType = "TIMESTAMP";
	   defaultValue = "00:00:00.000";
   }   
   else if (typeName.equals("VARBINARY"))
   {
	   //SQLdataType = "VARCHAR FOR BIT DATA ";
	   defaultValue = "0";
   }   
   else if (typeName.equals("VARCHAR"))
   {
	   //SQLdataType = "VARCHAR";
	   defaultValue = "EPSILON";
   }
   else 
   {
	   //SQLdataType = "Unknown Type";
       defaultValue = "EPSILON";
   }
	return defaultValue;
}
	
	public Object  getJavaFromSQLDataType(String typeName)
	{
		Object dataType = null;
	if(typeName.equals("BIGINT"))
   {
	   dataType = "Integer";
   }
   else if (typeName.equals("CHAR FOR BIT DATA"))
   {
	   dataType = "BINARY";
   }   
   else if (typeName.equals("BOOLEAN"))
   {
	   dataType  = "BOOLEAN";
   }
   else if (typeName.equals("CHAR FOR BIT DATA"))
   {
	   dataType  = "BOOLEAN";
   }   
   else if (typeName.equals("BLOB (JDBC 2.0 and up)"))
   {
	   dataType = "BLOB";
   }   
   else if (typeName.equals("CHAR"))
   {
	   dataType = "STRING";
   }   
   else if (typeName.equals("JDBC 2.0 and up"))
   {
	   dataType = "CLOB";
   }   
   else if (typeName.equals("DATE"))
   {
	   dataType = "DATE";
   }   
   else if (typeName.equals("DECIMAL"))
   {
	   dataType = "DECIMAL";
   }   
   else if (typeName.equals("DOUBLE"))
   {
	   dataType = "DOUBLE";
   }   
   else if (typeName.equals("DOUBLE PRECISION2"))
   {
	    dataType = "FLOAT";
   }   
   else if (typeName.equals("INTEGER"))
   {
	   dataType = "INTEGER";
   }   
   else if (typeName.equals("BIGINT"))
   {
	   dataType = "LONG VARCHAR FOR BIT DATA";
   }   
	
   else if (typeName.equals("LONG VARCHAR"))
   {
	   dataType = "STRING";
   }   
   else if (typeName.equals("NULL"))
   {
	   dataType = "STRING";
   }   
   else if (typeName.equals("DECIMAL"))
   {
	    dataType = "NUMERIC";
   }   
   else if (typeName.equals("REAL"))
   {
	    dataType = "REAL";
   }   
   else if (typeName.equals("SMALLINT"))
   {
	   dataType = "SMALLINT";
   }   
   else if (typeName.equals("SQLXML3"))
   {
	   dataType = "XML";
   }   
   else if (typeName.equals("TIME"))
   {
	   dataType = "TIME";
   }   
   else if (typeName.equals("TIMESTAMP"))
   {
	   dataType= "TIMESTAMP";
   }   
   else if (typeName.equals("VARCHAR FOR BIT DATA "))
   {
	   dataType = "STRING";
   }   
   else if (typeName.equals("VARCHAR"))
   {
	   dataType = "STRING";
   }
   else 
   {
	   dataType = "STRING";
   }
	return dataType;
}	
	
	
	
	
	
}
